package com.icode.core.dto.user;

import com.icode.core.model.user.Province;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xianfei
 * Date: 15-4-7
 * Time: 上午10:36
 * To change this template use File | Settings | File Templates.
 */
public class ProvinceDTO {

    private String id;
    private String provinceName;

    public ProvinceDTO() {
    }

    public ProvinceDTO(String id, String provinceName) {
        this.id = id;
        this.provinceName = provinceName;
    }

    public static ProvinceDTO toDTO(Province province) {
        return new ProvinceDTO(String.valueOf(province.id()), province.name());
    }

    public static List<ProvinceDTO> toDTOs(List<Province> provinces) {
        List<ProvinceDTO> provinceDTOs = new ArrayList<>();
        for (Province p : provinces) {
            ProvinceDTO provinceDTO = toDTO(p);
            provinceDTOs.add(provinceDTO);
        }
        return provinceDTOs;
    }

    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }

    public String getProvinceName() {
        return provinceName;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }
}
